#--------------------- Items 家具类

class Item:
    def __init__(self,name,area) -> None:
        
        self.name = name
        self.area = area 
    
    def __str__(self) -> str:
        return "str家具名称：{},占地面积：{}".format(self.name,self.area)    
    def __repr__(self) -> str:
        return "repr家具名称：{},占地面积：{}".format(self.name,self.area)    
#--------------------- House 家居类
class House:
    def __init__(self,addr,area) -> None:
        self.address = addr
        self.area = area
        
        #剩余面积
        self.free_area = self.area 
        self.items = []
        
    def add_item(self,item):
        
        if self.free_area >= item.area:
            
            self.items.append(item)
            self.free_area -= item.area
            print("添加成功",item.name)    

        else:
            print("面积不足，添加失败",item.name)    
        
    def __str__(self) -> str:
         return "房子地址：{}, 套内面积：{} ,剩余面积：{}".format(self.address,self.area,self.free_area)
        
item1 = Item("沙发",10)        
item2 = Item("餐桌餐具",30)        
item3 = Item("家庭影院",80)        

print(item1)
print(item2)

house = House("黄金水岸",100)
print(house)

house.add_item(item1)
house.add_item(item2)
house.add_item(item3)

print(house,"家具个数",len(house.items))
print(house.items)








